package net.maku.association.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import net.maku.association.convert.InterestAssociationConvert;
import net.maku.association.entity.InterestAssociationEntity;
import net.maku.association.query.InterestAssociationQuery;
import net.maku.association.service.InterestAssociationService;
import net.maku.association.vo.InterestAssociationVO;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.framework.security.user.SecurityUser;
import net.maku.framework.security.user.UserDetail;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 兴趣协会
*
* @author 阿沐 babamu@126.com
* @since 1.0.0 2025-04-26
*/
@RestController
@RequestMapping("association/interest")
@Tag(name="兴趣协会")
@AllArgsConstructor
public class InterestAssociationController {
    private final InterestAssociationService interestAssociationService;

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<PageResult<InterestAssociationVO>> page(@ParameterObject @Valid InterestAssociationQuery query){
        Long userId = SecurityUser.getUserId();
        PageResult<InterestAssociationVO> page = interestAssociationService.page(query,userId);

        return Result.ok(page);
    }

    @GetMapping("{id}")
    @Operation(summary = "信息")
    public Result<InterestAssociationVO> get(@PathVariable("id") Long id){
        Long userId = SecurityUser.getUserId();
        InterestAssociationVO entity = interestAssociationService.selectById(id,userId);

        return Result.ok(entity);
    }


}